package org.jwebuilder.parsers;

import java.io.File;
import java.io.IOException;
import java.util.Map;

import org.apache.commons.io.FileUtils;
import org.mvel.TemplateInterpreter;

public class TextParser
{
	public static String parse(String template, Object contextObj, Map<String, Object> vars)
	{
		return TemplateInterpreter.parse(template, contextObj, vars).toString();
	}

	public static String parse(File templateFile, Object contextObj, Map<String, Object> vars, String templateEncoding) throws IOException
	{
		return parse(FileUtils.readFileToString(templateFile, templateEncoding), contextObj, vars);
	}
}